package com.qf.filters;

import com.qf.feign.CacheService;
import com.qianfeng.smsplatform.common.constants.CacheConstants;
import com.qianfeng.smsplatform.common.model.Standard_Submit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/*
 * @Data: 2021/7/15 19:02
 * */
//@Component
public class BlackFilterWithRedisSet implements FiltersChain {

    private CacheService cacheService;
    @Autowired
    public void setCacheService(CacheService cacheService) {
        this.cacheService = cacheService;
    }

    @Override
    public boolean dealSms(Standard_Submit submit) {
        //当前的过滤器进行的操作是判断手机号是不是黑名单
        //黑名单我们通过set的方式保存在了redis中
//      判断当前手机号是否在set  集合中
//        获取手机号
        String destMobile = submit.getDestMobile();
//      在本地中进行判断
        Boolean result = cacheService.isMember(CacheConstants.CACHE_BLACK_KEY, destMobile);
        if(result){
            System.out.println(destMobile+"在黑名单中");
                return true;
        }else {
            System.out.println(destMobile+"bububu在黑名单中");
            return false;
        }



    }
}
